package com.eternal.base.config;

import android.app.Application;

import com.eternal.base.IModuleInit;

import io.reactivex.annotations.Nullable;

/**
 * @author li
 */
public class ModuleLifecycleConfig {
    public static void initAhead(@Nullable Application application){
        for (String cln:ModuleLifecycleReflexes.MODULES_INIT){
            try{
                Class<?> clz=Class.forName(cln);
                IModuleInit init= (IModuleInit) clz.newInstance();
                init.initAhead(application);
            } catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) {
                e.printStackTrace();
            }
        }
    }

    public static void initLow(@Nullable Application application){
        for (String cln:ModuleLifecycleReflexes.MODULES_INIT){
            try{
                Class<?> clz=Class.forName(cln);
                IModuleInit init= (IModuleInit) clz.newInstance();
                init.initLow(application);
            } catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) {
                e.printStackTrace();
            }
        }
    }
}
